<template>
	<view class="content">
		<scroll-view scroll-y style="height: 100vh;">
			<view class="content-box">
				<!-- 页面内容 -->
				<pdf :flag="flag" :pdfUrl="pdfUrl" />
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import pdf from '../../components/pdf.vue'
	export default {
		components: {
			pdf
		},
		props: {},
		data() {
			return {
				flag: true,
				pdfUrl: ''
			}
		},
		onLoad(option) {
			if (process.env.VUE_APP_PLATFORM === 'h5') {
				this.preventPullDownRefresh();
			}
			if (option.flag) {
				this.flag = option.flag == 0 ? true : false
				this.pdfUrl = option.pdfUrl
			}
		},
		methods: {
			preventPullDownRefresh() {
				// 禁用页面顶部的下拉刷新
				document.body.addEventListener('touchmove', this.handleTouchMove, {
					passive: false
				});
			},
			handleTouchMove(e) {
				// 判断页面是否滚动到顶部
				if (window.scrollY === 0) {
					e.preventDefault(); // 禁止下拉刷新
				}
			}
		}
	}
</script>

<style scoped>
	.content {
		width: 100%;
		height: 100%;
		overflow: hidden;
	}
</style>